<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>做T神器</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <!-- Sweet Alert -->
    <link href="/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <!-- 弹窗-->
    <script src="../../tanchuan/js/jquery-2.0.0.min.js"></script>
    <link href="../../tanchuan/css/displaystyle.css" rel="stylesheet" />
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shCore.js"></script>
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shBrushJScript.js"></script>
    <link href="../../tanchuan/js/syntaxhighlighter_3.0.83/styles/shCoreRDark.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Window.min.js"></script>
    <link href="../../tanchuan/js/NZ-Plugin/Css/NZ-Window.min.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Drag.min.js"></script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                                <h3 th:if="${not #strings.isEmpty(email)}" style="font-family:arial;font-size:30px;" >做T神器
                                    <a style="font-family:arial;font-size:10px;" href="https://www.yuque.com/yonghengguodu-fohhs/us5yes/gp8dkuq417t5bgrr?singleDoc# 《做T神器使用说明》" >查看使用方法</a>
                                    <a style="font-family:arial;font-size:10px;color: red" th:text="'预警邮箱：'+${email}"></a>
                                </h3>

                                <h3 th:if="${#strings.isEmpty(email)}" style="font-family:arial;font-size:30px;" >做T神器
                                    <a style="font-family:arial;font-size:10px;" href="https://www.yuque.com/yonghengguodu-fohhs/us5yes/gp8dkuq417t5bgrr?singleDoc# 《做T神器使用说明》" >查看使用方法</a>
                                </h3>
                        </div>
                        <div class="ibox-tools">
                            <div class="input-group">
                                <input type="text" id="codeName" placeholder="添加新股票" class="input input-sm form-control">
                                <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-white" onclick="handleClick()">
                                            <i class="fa fa-plus" onclick="handleClick()"></i> 添加</button>
                                </span>
                            </div>
                            <div class="input-group" th:if="${#strings.isEmpty(email)}">
                                    <input th:text="${email}" id="email" placeholder="设置邮箱，微信消息会收到邮箱消息提醒，只保留一天" class="input input-sm form-control">
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-white" onclick="addEmail()">
                                            <i class="fa fa-plus" onclick="addEmail()"></i> 添加邮箱</button>
                                     </span>
                            </div>
                        </div>
                        <br class="ibox-content">

                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="100">
                                <thead>
                                <tr>
                                    <th data-toggle="true" >序号</th>
                                    <th data-toggle="true">公司简称</th>
                                    <th style="font-family:arial;font-size:15px;">涨跌</th>
                                    <th data-toggle="true">状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                    <tr class="gradeX" th:each="tag,resultStat:${zuotList}"  >
                                        <td th:text="''+${resultStat.count}" style="font-family:arial;font-size:15px;"></td>
                                        <td  hidden="hidden" th:text="${tag.stockCode}"  th:id="'code_'+${tag.stockCode}" class="stockCode"></td>
                                         <td th:text="${tag.stockName}"  style="font-family:arial;font-size:20px;" ></td>
                                        <!-- 涨跌 -->
                                        <i th:if="${tag.priceChangePercentage} ge 0" >
                                            <td th:text="${tag.priceChangePercentage}+'%'" style="font-family:arial;color:red;font-size:20px;" th:id="'zd_'+${tag.stockCode}"></td>
                                        </i>
                                        <i th:if="${tag.priceChangePercentage} lt 0" >
                                            <td th:text="${tag.priceChangePercentage}+'%'" style="font-family:arial;color:green;font-size:20px;" th:id="'zd_'+${tag.stockCode}"></td>
                                        </i>

                                        <i th:if="${tag.isFlash} eq 1" >
                                            <td th:text="监控中"  style="font-family:arial;color:red;font-size:20px;" th:id="'yj_'+${tag.stockCode}" onclick="queryData()" ></td>
                                        </i>
                                        <i th:if="${tag.isFlash} eq 0" >
                                            <td th:text="休市1"  style="font-family:arial;color:grey;font-size:20px;" th:id="'yj_'+${tag.stockCode}" onclick="queryData()" ></td>
                                        </i>
                                        <td th:text="删除"  style="font-family:arial;color:grey;font-size:10px;" th:id="'yj_del_'+${tag.stockCode}" onclick="deleteStockKey(this)" ></td>
                                        <!-- 成交额 -->
<!--                                        <i th:if="${tag.mll} ge 0" >-->
<!--                                            <td th:text="${tag.cje/100000000}+'亿'" style="font-family:arial;color:red;font-size:20px;"></td>-->
<!--                                        </i>-->
<!--                                        <i th:if="${tag.mll} lt 0" >-->
<!--                                            <td th:text="${tag.cje/100000000}+'亿'" style="font-family:arial;color:green;font-size:20px;"></td>-->
<!--                                        </i>-->
                                    </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="5">
                                        <ul class="pagination pull-right"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
    </div>
<!--    <script src="/js/jquery.min.js?v=2.1.4"></script>-->
<!--    <script src="/js/bootstrap.min.js?v=3.3.5"></script>-->
    <script src="/js/plugins/footable/footable.all.min.js"></script>
<!--    <script src="/js/content.min.js?v=1.0.0"></script>-->

    <!--    <script src="/js/jquery.min.js?v=2.1.4"></script>-->
    <script src="/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/js/plugins/sparkline/jquery.sparkline.min.js"></script>
    <script src="/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="/js/demo/peity-demo.min.js"></script>
    <script src="/js/plugins/gritter/jquery.gritter.min.js"></script>
    <script src="/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(document).ready(function(){$(".footable").footable();$(".footable2").footable()});
        /**
         * 添加
         * */
        function handleClick() {
            var code = $("#codeName").val();
            if (code == null || code == "" || code.length != 6) {
                if (code.length != 6) {
                    swal({title: "请输入正确的股票代码", text: ""});
                } else {
                    swal({title: "请输入股票代码", text: ""});
                }
            } else {
                if (code.startsWith("6", 0)) {
                    code = "sh" + code;
                } else {
                    code = "sz" + code;
                }
                $.ajax({
                    url: '/zuot/ajaxRequestAddStockKey',
                    type: "get",
                    withCredentials: true,
                    data: {"keyWords": code},
                    success: function (data) {
                        swal({title: code, text: "添加成功"});
                        window.location.reload();
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        swal({title: "查询失败，请检查股票代码！", text: ""});
                    },
                });
            }
        }


        function deleteStockKey(object){
            var code=object.id;
            code=code.replace("yj_del_", "");
            $.ajax({
                url: '/zuot/ajaxRequestDelStockKey',
                type: "get",
                data: {"keyWords": code},
                withCredentials: true,
                success: function (data) {
                    swal({title: "删除成功", text: ""});
                    window.location.reload();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    swal({title: "删除失败！", text: ""});
                },
            });

        }

        function addEmail(object) {
            var email = $('#email').val();
            //匹配规则
            var reg = /^(?=\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$).{0,64}$/;
            if (email == "") {
                swal({title: "邮箱不能为空，请输入邮箱！", text: ""});
                //邮箱格式错误
            } else if (email.match(reg) == null) {
                swal({title: "邮箱格式不正确，请修改邮箱格式！", text: ""});
            } else {
                $.ajax({
                    url: '/zuot/ajaxRequestAddEmail',
                    type: "get",
                    withCredentials: true,
                    data: {"email": email},
                    success: function (data) {
                        swal({title: "添加成功", text: ""});
                        window.location.reload();
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        swal({title: "删除失败！", text: ""});
                    },
                });
            }
        }

    </script>

    <script>
        var isFlash = [[${isFlash}]];

        setInterval(queryData, 5000);
        //Ajax请求后台数据
       function queryData() {
           if (1 == isFlash) {
               var elements = document.querySelectorAll(".stockCode");
               elements.forEach(function (element) {
                   var code = element.textContent;
                   if (code.startsWith("6", 0)) {
                       code = "sh" + code;
                   } else {
                       code = "sz" + code;
                   }
                   var url_ = 'http://qt.gtimg.cn/q=' + code;

                   $.ajax({
                       url: url_,
                       type: "get",
                       success: function (data) {
                           $.ajax({
                               url: '/zuot/ajaxRequest',
                               type: "get",
                               withCredentials: true,
                               data: {"data": data},
                               success: function (data1) {
                                   var stockinfo = JSON.parse(data1);
                                   var code= stockinfo.stockCode.replace("sh", "").replace("sz", "");

                                   var idCode = "#code_" + code;
                                   var idZhangDie = "#zd_" + code;
                                   var idYj = "#yj_" + code;
                                   $(idZhangDie).html(stockinfo.priceChangePercentage+"%");
                                   // 获取id为yj_601360的元素
                                   let tdElement = document.getElementById(idYj);
                                   // 修改innerText属性值为"新值"
                                   tdElement.innerText = "监控中";

                                   if(stockinfo.priceChangePercentage<0){
                                       $(idZhangDie).css({"color":"green","font-size":"20px"});
                                   }
                                   if(stockinfo.priceChangePercentage>=0){
                                       $(idZhangDie).css({"color":"red","font-size":"20px"});
                                   }
                                   if (1 == stockinfo.tFlags) {
                                       //alert("【"+stockinfo.stockName+"】做T  触发时间："+stockinfo.yjTime);
                                       swal({
                                           title: "【" + stockinfo.stockName + "】做T",
                                           text: "触发时间：" + stockinfo.yjTime
                                       });
                                   }
                                   isFlash = stockinfo.isFlash;
                               }
                           });
                       }
                   });
               });
           }
       }
        function stockMinutes30(object){
            var code=object.id;
            $.NZ_Window.show({
                url: '/stockMinutes30?code='+code,
                width: 1500,
                height: 1000,
                operate: {
                    btn_Close: true, //关闭按钮
                    btn_Max: true, //最大化按钮
                    btn_Refresh: true, //刷新按钮
                    btn_NewWindow: true, //新窗口按钮
                    resize: true //调整窗口大小按钮
                }
            });
            // window.open('/stockMinutes?code='+code,'','width=2000,height=1000,left=200,top=300,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
        }

        function stockReDianKan24Hour(object){
            var code=object.id;
            $.NZ_Window.show({
                url: '/ths/stockKanDian?type=24Hour&code='+code,
                width: 1500,
                height: 1000,
                operate: {
                    btn_Close: true, //关闭按钮
                    btn_Max: true, //最大化按钮
                    btn_Refresh: true, //刷新按钮
                    btn_NewWindow: true, //新窗口按钮
                    resize: true //调整窗口大小按钮
                }
            });
            // window.open('/stockMinutes?code='+code,'','width=2000,height=1000,left=200,top=300,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
        }
        function openUrl(url){
            window.open("https://www.yuque.com/yonghengguodu-fohhs/us5yes/gp8dkuq417t5bgrr?singleDoc# 《做T神器使用说明》","_blank");
        }

    </script>
</body>

</html>